import Vuex from 'vuex'
import Vue from 'vue'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        dialog: {
            visible: false,
            onClose: '',    // function
        },
        menus: []
    },
    getters: {
        menus (state) {
            return state.menus
        }
    },
    mutations: {
        showDialog (state, obj) {
            Object.assign(state.dialog, obj)
            state.dialog.visible = true
        },
        closeDialog (state) {
            state.dialog.visible = false
        },
        setMenus (state, menus) {
            state.menus = menus
        }
    }
})


export default store